package cn.tedu.zhyl.file.controller;

import cn.tedu.zhyl.base.response.JsonResult;
import cn.tedu.zhyl.file.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
 * 图片上传接口
 */

@RestController
@RequestMapping("/fileUpload")
public class FileUploadController {
    @Autowired
    private FileUploadService fileUploadService;
    @PostMapping
    public JsonResult<String> fileUpload(@RequestParam("file") MultipartFile file){
        String url = fileUploadService.fileUpload(file);
        return JsonResult.ok(url);
    }
    @GetMapping("/delete")
    public JsonResult remove(String filename){
        fileUploadService.deleteFile(filename);
        return JsonResult.ok();
    }
}
